package cn.faster.sys.controller;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import java.util.*;
import cn.faster.common.result.ResultBean;
import cn.faster.sys.service.SysRoleMenuCenterService;
import cn.faster.sys.entity.SysRoleMenuCenter;

/**
 * <p>
 * 角色权限中间表 前端控制器
 * </p>
 *
 * @author xiaoCoder
 * @date 2021-06-10
 */
@RestController
@CrossOrigin
@AllArgsConstructor
@Api(value = "角色权限中间表",tags = "角色权限中间表")
@RequestMapping("/sys/roleMenuCenter")
public class SysRoleMenuCenterController {

    private final SysRoleMenuCenterService sysRoleMenuCenterService;

    @ApiOperation(value = "获取roleMenuCenter根据id",notes="")
    @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Integer")
    @GetMapping("/getById")
    public ResultBean roleMenuCenter(@RequestParam(value = "id") Long id) throws Exception {

        SysRoleMenuCenter sysRoleMenuCenter = sysRoleMenuCenterService.getRoleMenuCenterById(id);
        ResultBean resultBean = new ResultBean();
        resultBean.fillData(sysRoleMenuCenter);
        return resultBean;
    }

    @ApiOperation(value = "获取roleMenuCenter列表",notes="")
    @ApiImplicitParam(name = "map", value = "roleMenuCenter实体中的参数", dataType ="Map")
    @GetMapping("")
    public ResultBean roleMenuCenterList(@RequestParam(required = false) Map<String, Object> map) throws Exception {

        List<SysRoleMenuCenter> sysRoleMenuCenterList = sysRoleMenuCenterService.listRoleMenuCenter(map);
        ResultBean resultBean = new ResultBean();
        resultBean.fillData(sysRoleMenuCenterList);
        return resultBean;
    }


    @ApiOperation(value = "添加roleMenuCenter",notes="新增一条roleMenuCenter")
    @ApiImplicitParam(name = "roleMenuCenter", value = "roleMenuCenter实体中的参数", required = true, dataType = "RoleMenuCenter")
    @PostMapping("")
    public ResultBean roleMenuCenterAdd(@RequestBody SysRoleMenuCenter sysRoleMenuCenter) throws Exception {

        Integer flag = sysRoleMenuCenterService.addRoleMenuCenter(sysRoleMenuCenter);
        ResultBean resultBean = new ResultBean();
        resultBean.fillData(flag);
        return resultBean;
    }

    @ApiOperation(value = "修改roleMenuCenter",notes="根据id修改role_Menu_center")
    @ApiImplicitParam(name = "roleMenuCenter", value = "roleMenuCenter实体", required = true, dataType = "RoleMenuCenter")
    @PutMapping("")
    public ResultBean roleMenuCenterUpdate(@RequestBody SysRoleMenuCenter sysRoleMenuCenter) throws Exception {

        Integer flag = sysRoleMenuCenterService.updateRoleMenuCenter(sysRoleMenuCenter);
        ResultBean resultBean = new ResultBean();
        resultBean.fillData(flag);
        return resultBean;
    }
    @ApiOperation(value = "物理删除roleMenuCenter",notes="根据id物理删除roleMenuCenter")
    @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Integer")
    @DeleteMapping("/{id}")
    public ResultBean roleMenuCenterDelete(@PathVariable(name = "id") Integer id) throws Exception {

        Integer flag = sysRoleMenuCenterService.deleteRoleMenuCenterById(id);
        ResultBean resultBean = new ResultBean();
        resultBean.fillData(flag);
        return resultBean;
    }

    @ApiOperation(value = "逻辑删除roleMenuCenter",notes="根据id逻辑删除roleMenuCenter")
    @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Integer")
    @PostMapping("/removeById")
    public ResultBean roleMenuCenterRemove(@RequestParam(value = "id") Integer id) throws Exception {

        Integer flag = sysRoleMenuCenterService.removeRoleMenuCenterById(id);
        ResultBean resultBean = new ResultBean();
        resultBean.fillData(flag);
        return resultBean;
    }
}
